import React, { PureComponent } from 'react';
import { connect } from 'dva';
import { Form } from '@ant-design/compatible';
import '@ant-design/compatible/assets/index.css';
import { Tabs, Modal, message, Tooltip, Popconfirm } from 'antd';
import { InfoTipsC, NoQueryC, DATA_ENTRY, AdvancedSearch, TableC, FirstHeaderC, SecondHeaderC, PrimaryC } from '../../../comps';
import myStyle from './index.less';

import InitialSplitC from '../InitialSplit';
import SeriesProductC from './seriesProductC';

@connect(({ seriesProductManageM, initialSplitM, userM: user, loading }) => ({
  seriesProductManageM,
  initialSplitM,
  user,
  loading,
}))
@Form.create()
export default class SeriesProductManageC extends PureComponent {
  state = {
    seriesInfo: undefined, //编辑的系列产品
    pageStatus: 1, //1是系列产品列表 2是初始拆分页面
    seriesProductInfo: undefined, //初始拆分对应的产品数据
  };
  componentDidMount() {}

  onCloseSplit = () => {
    //回到主页面
    this.setState({
      pageStatus: 1,
      initSeriesId: this.state.seriesProductInfo?.seriesProductId,
      seriesProductInfo: undefined,
    });
  };
  getSeriesProductInfo = (e, currentSelectSeries) => {
    this.setState({
      pageStatus: 2, //进入初始拆分页面 拿到对应的系列产品信息
      seriesProductInfo: e,
      currentSelectSeries: currentSelectSeries,
    });
  };
  render() {
    return (
      <div className={myStyle.seriesProductManage}>
        {this.state.pageStatus == 1 && (
          <SeriesProductC initSeriesId={this.state.initSeriesId} isAll={!this.state.currentSelectSeries?.seriesProductId} getSeriesProductInfo={this.getSeriesProductInfo} />
        )}
        {this.state.pageStatus == 2 && <InitialSplitC onClose={this.onCloseSplit} seriesProductInfo={this.state.seriesProductInfo} />}
      </div>
    );
  }
}
